<?php
$rows = array();
$rows[] = array('供应商:',$demand['dept_name'],'','','','','单号',$demand['sno']);  
$rows[] = array('采购类型',DemandHelper::type2text($demand['type']),'','','','','日 期',date('Y-m-d H:i', $demand['addtime']));
$rows[] = array('','','','','','','','');  
$rows[] = ($demand['type']==0)? array('材料编号', '材料名称', '品牌', '规格', '单位', '结存数量', '最低库存', '采购数量', '用途','备注') : array('材料编号', '材料名称', '品牌', '规格', '单位', '采购数量', '用途','备注') ;
if($demand['items']) {
    
    $amount = 0; 
      
    foreach($demand['items'] as $ware){
            $rows[] = ($demand['type']==0)
                        ?
                        array( 
                            $ware['sno'], 
                            $ware['name'], 
                            $ware['brand'],
                            $ware['specific'],
                            $ware['unit'],
                            $ware['_amount'],
                            $ware['cordon'], 
                            $ware['amount'], 
                            $ware['remark_use'],
                            $ware['remark']
                            )
                        :
                        array( 
                            $ware['sno'], 
                            $ware['name'], 
                            $ware['brand'],
                            $ware['specific'],
                            $ware['unit'],
                            $ware['amount'], 
                            $ware['remark_use'],
                            $ware['remark']
                            );               

    }

}
Exporter::csv($rows, '采购订单明细 - '.DemandHelper::type2text($demand['type']));

?>
